package com.zhaoqi.hr.controller;

import com.zhaoqi.hr.dto.response.ApiResponse;
import com.zhaoqi.hr.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * OSS文件上传控制器
 */
@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 获取OSS上传签名
     */
    @PostMapping("/signature")
    @PreAuthorize("hasRole('ADMIN')")
    public ApiResponse<Map<String, String>> getUploadSignature(
            @RequestBody Map<String, String> request) {
        
        String fileName = request.get("fileName");
        String fileType = request.get("fileType");
        
        Map<String, String> signature = ossService.generateUploadSignature(fileName, fileType);
        return ApiResponse.success(signature);
    }
}
